<template>
	<view>
	  <view class="cu-bar bg-white search" :style="[{top:CustomBar + 'px'}]">
	  	<view class="search-form round">
	  		<text class="cuIcon-search"></text>
	  		<input type="text" placeholder="输入搜索的帖名" confirm-type="search" :value="inputValue" @input="getValue" @confirm="show"></input>
	  	</view>
	  	<view class="action">
	  		<button class="cu-btn bg-gradual-green shadow-blur round" @click="show">搜索</button>
	  	</view>
	  </view>
	  <view v-if="showCheck">
	  		  文件名称:{{title}}  提交用户:{{userName}}
			  <text class="cuIcon-down" style="float: right;" @click="downLoad(index)"></text> 
	  </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data:[],
				showCheck:false,
				downLoadUrl:[],
				inputValue:''
			}
		},
		methods: {
		  show(){
			var that=this; 
		  	uni.request({
		  		url: 'http://summer.codinglink.tech:65001/post/getPosts',
		  		method: 'POST',
		  		data: {
					title:that.inputValue
				},
		  		success: res => {
		  			that.data=res.data.data;
					that.showCheck=true;
		  		},
		  		fail: () => {
					uni.showToast({
						title: '找不到您查找的内容',
						icon: 'none'
					});
				},
		  		complete: () => {}
		  	});
		  },
		  downLoad(index){  
			uni.request({
				url: 'http://rap2api.taobao.org/app/mock/286869/user/searchfile',
				method: 'GET',
				data: {
				},
				success: res => {
					const filePath=res.data.path;
					console.log(filePath);
					uni.downloadFile({
						URL:'filePath',
						success: res =>{
							uni.showToast({
								title: '下载成功'
							});
						},
						fail: res=>{
							uni.showToast({
								title:'下载失败',
								icon:'none'
							});
						}
					})
				},
				fail: () => {},
				complete: () => {}
			});  
		  },
		 getValue(e){
		      this.inputValue=e.detail.value;
		  }
		}
	}
</script>

<style>

</style>
